import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import path from "path";
// 服务端渲染的时候 需要将按需引入关闭掉，不然会报错
// 如果不使用服务端渲染的时候 还是可以使用elementPlus按需加载的方式
// import AutoImport from 'unplugin-auto-import/vite'
// import Components from 'unplugin-vue-components/vite'
// import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import vitePluginCompression from "vite-plugin-compression";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vitePluginCompression()
    // AutoImport({
    //   resolvers: [ElementPlusResolver()]
    // }),
    // Components({
    //   resolvers: [ElementPlusResolver()]
    // })
  ],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src")
    }
  },
  css: {
    preprocessorOptions: {
      scss: {
        additionalData: "@import \"@/assets/scss/variable.scss\";@import \"@/assets/scss/main.scss\";"
      }
    }
  },
  // Vite代理服务器请求
  server: {
    host: "localhost",
    port: 5173, // 服务器端口号
    // 为开发服务器自定义代理规则
    proxy: {
      // 自定义接口接口请求时的后缀
      "/release": {
        target: "http://110.42.184.111", // 需要代理的目标地址
        rewrite: path => path.replace(/^\/release/, "") // 重写路径
      }
    }
  }
});
